﻿using Mengsk.ProxyDelivery.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Mengsk.ProxyDelivery.App.UI.Accounting
{
    /// <summary>
    /// Interaction logic for SellerChargeWindow.xaml
    /// </summary>
    public partial class SellerChargeWindow : Window
    {

        private SellerChargeService sellerChargeService = ServiceContainer.GetService<SellerChargeService>();

        public SellerChargeWindow()
        {
            InitializeComponent();
        }

        private void btnCharge_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int sellerId = int.Parse(this.tbSellerId.Text);
                float money = float.Parse(this.tbMoney.Text.Trim());
                string password = this.pbPassword.Password;
                string comment = this.tbComment.Text.Trim();

                if (string.IsNullOrWhiteSpace(comment))
                {
                    MessageBox.Show("输入充值信息");
                    return;
                }
                if ((int)(money * 100) < 1)
                {
                    MessageBox.Show("充值金额必须大于0.01元");
                    return;
                }
                password = Utls.MD5Util.Md5(password);
                this.sellerChargeService.Chargeforseller(sellerId, money, comment, password);
                MessageBox.Show("充值成功");
                this.DialogResult = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
